<<<<<<< HEAD ||||||| merged common ancestors ======= >>>>>>> 371ff05b569a6264d9798b347807497f5edc6dbd Ordination analysis

Ordination analysis

Full examples for standard ordination techniques applied to phyloseq data, based on the phyloseq ordination tutorial. For handy wrappers for some common ordination tasks in microbiome analysis, see landscaping examples

Load example data:

Sample ordination

Project the samples with the given method and dissimilarity measure.

Multidimensional scaling (MDS / PCoA)

<<<<<<< HEAD
plot_ordination(pseq, ord, color = "nationality") +
                geom_point(size = 5)

||||||| merged common ancestors
plot_ordination(pseq, ord, color = "nationality") +
                geom_point(size = 5)

=======

>>>>>>> 371ff05b569a6264d9798b347807497f5edc6dbd

Canonical correspondence analysis (CCA)

<<<<<<< HEAD
# With samples
pseq.cca <- ordinate(pseq, "CCA")
p <- plot_ordination(pseq, pseq.cca,
       type = "samples", color = "nationality")
p <- p + geom_point(size = 4)
print(p)

# With taxa:
p <- plot_ordination(pseq, pseq.cca,
       type = "taxa", color = "Phylum")
p <- p + geom_point(size = 4)
print(p)

||||||| merged common ancestors
# With samples
pseq.cca <- ordinate(pseq, "CCA")
p <- plot_ordination(pseq, pseq.cca,
       type = "samples", color = "nationality")
p <- p + geom_point(size = 4)
print(p)

# With taxa:
p <- plot_ordination(pseq, pseq.cca,
       type = "taxa", color = "Phylum")
p <- p + geom_point(size = 4)
print(p)

=======

>>>>>>> 371ff05b569a6264d9798b347807497f5edc6dbd

Split plot

<<<<<<< HEAD
plot_ordination(pseq, pseq.cca,
              type = "split", shape = "nationality", 
                  color = "Phylum", label = "nationality")

||||||| merged common ancestors
plot_ordination(pseq, pseq.cca,
              type = "split", shape = "nationality", 
                  color = "Phylum", label = "nationality")

=======

>>>>>>> 371ff05b569a6264d9798b347807497f5edc6dbd

t-SNE

t-SNE is a popular new ordination technique.

<<<<<<< HEAD
library(vegan)
library(microbiome)
library(Rtsne) # Load package
set.seed(423542)

method <- "tsne"
trans <- "hellinger"
distance <- "euclidean"

# Distance matrix for samples
ps <- microbiome::transform(pseq, trans)

# Calculate sample similarities
dm <- vegdist(otu_table(ps), distance)

# Run TSNE
tsne_out <- Rtsne(dm, dims = 2) 
proj <- tsne_out$Y
rownames(proj) <- rownames(otu_table(ps))

library(ggplot2)
p <- plot_landscape(proj, legend = T, size = 1) 
print(p)

||||||| merged common ancestors
library(vegan)
library(microbiome)
library(Rtsne) # Load package
set.seed(423542)

method <- "tsne"
trans <- "hellinger"
distance <- "euclidean"

# Distance matrix for samples
ps <- microbiome::transform(pseq, trans)

# Calculate sample similarities
dm <- vegdist(otu_table(ps), distance)

# Run TSNE
tsne_out <- Rtsne(dm, dims = 2) 
proj <- tsne_out$Y
rownames(proj) <- rownames(otu_table(ps))

library(ggplot2)
p <- plot_landscape(proj, legend = T, size = 1) 
print(p)

=======

>>>>>>> 371ff05b569a6264d9798b347807497f5edc6dbd
<<<<<<< HEAD

Leo Lahti, Sudarshan Shetty et al. 2018-11-19

||||||| merged common ancestors

Leo Lahti, Sudarshan Shetty et al. 2018-07-22

=======

Leo Lahti, Sudarshan Shetty et al. 2018-11-15

>>>>>>> 371ff05b569a6264d9798b347807497f5edc6dbd